package com.meitianhui.convenitenbuy.module.store.http;

import com.meitianhui.convenitenbuy.base.BaseArrayResponse;
import com.meitianhui.convenitenbuy.base.BaseMapResponse;
import com.meitianhui.convenitenbuy.base.BaseResponse;
import com.meitianhui.convenitenbuy.http.RetrofitHelper;
import com.meitianhui.convenitenbuy.main.model.bean.HyphenateInfo;
import com.meitianhui.convenitenbuy.module.order.model.bean.EmptyInfo;
import com.meitianhui.convenitenbuy.module.order.model.bean.FightGroupShop;
import com.meitianhui.convenitenbuy.module.store.model.CouponCardInfo;
import com.meitianhui.convenitenbuy.module.store.model.DSKBean;
import com.meitianhui.convenitenbuy.module.store.model.DskStoreDetailBean;
import com.meitianhui.convenitenbuy.module.store.model.GroupSaleInfo;
import com.meitianhui.convenitenbuy.module.store.model.OneLotteryParticipateBean;
import com.meitianhui.convenitenbuy.module.store.model.PayInfoBean;
import com.meitianhui.convenitenbuy.module.store.model.StoreDetailCount;
import com.meitianhui.convenitenbuy.module.store.model.StoreDetailInfo;
import com.meitianhui.convenitenbuy.module.store.model.StoreInfo;
import com.meitianhui.convenitenbuy.module.store.model.StoreOneLotteryBean;
import com.meitianhui.convenitenbuy.module.store.model.StoreSelectedGood;
import com.meitianhui.convenitenbuy.module.store.model.StoreType;
import com.meitianhui.convenitenbuy.module.store.model.YYYLuckBean;
import com.meitianhui.convenitenbuy.util.RxUtils;

import retrofit2.http.Query;
import rx.Observable;

/**
 * Created by Administrator on 2017/11/1.
 */

public class StoreApiDataSource implements StoreApi {
    private static volatile StoreApiDataSource instance = null;
    private StoreApiDataSource(){}
    public static StoreApiDataSource getInstance() {
        if (instance == null) {
            synchronized (StoreApiDataSource.class) {
                if (instance == null) {
                    instance = new StoreApiDataSource();
                }
            }
        }
        return instance;
    }
    @Override
    public Observable<BaseResponse<StoreInfo>> getStoreList(@Query("app_token") String appToken, @Query("service") String service, @Query("page") String page, @Query("params") String params) {
        return RetrofitHelper.createApi(StoreApi.class, true, 0).getStoreList(appToken, service, page, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<StoreDetailInfo>> getStoreDetailInfo(@Query("app_token") String appToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(StoreApi.class, true, 0).getStoreDetailInfo(appToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<StoreDetailCount>> getStoreDetailCount(@Query("app_token") String appToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(StoreApi.class, true, 0).getStoreDetailCount(appToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseMapResponse> getStoreSelectedType(@Query("app_token") String appToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(StoreApi.class, true, 0).getStoreSelectedType(appToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<StoreSelectedGood>> getStoreSelectedGood(@Query("app_token") String appToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(StoreApi.class, true, 0).getStoreSelectedGood(appToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseArrayResponse<StoreType>> getStoreType(@Query("app_token") String appToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(StoreApi.class, true, 0).getStoreType(appToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<EmptyInfo>> operationCollect(@Query("app_token") String appToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(StoreApi.class, true, 0).operationCollect(appToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<HyphenateInfo>> getHyphenateInfo(@Query("user_token") String userToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(StoreApi.class, true, 1).getHyphenateInfo(userToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<GroupSaleInfo>> getGroupSale(@Query("app_token") String appToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(StoreApi.class, true, 0).getGroupSale(appToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<FightGroupShop>> getGroupSaleDetail(@Query("user_token") String userToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(StoreApi.class,true,1).getGroupSaleDetail(userToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<CouponCardInfo>> getCouponCard(@Query("app_token") String appToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(StoreApi.class, true, 0).getCouponCard(appToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<StoreOneLotteryBean>> getStoreOneLottery(@Query("app_token") String appToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(StoreApi.class, true, 0).getStoreOneLottery(appToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<PayInfoBean>> payOneLottery(@Query("user_token") String userToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(StoreApi.class, true, 1).payOneLottery(userToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<EmptyInfo>> payOneLotteryOrder(@Query("user_token") String userToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(StoreApi.class, true, 1).payOneLotteryOrder(userToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<OneLotteryParticipateBean>> getOneLotteryParticipate(@Query("user_token") String userToken, @Query("service") String service, @Query("page") String pageParams, @Query("params") String params) {
        return RetrofitHelper.createApi(StoreApi.class, true, 1).getOneLotteryParticipate(userToken, service, pageParams, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<YYYLuckBean>> getYYYData(@Query("user_token") String userToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(StoreApi.class, true, 1).getYYYData(userToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<EmptyInfo>> postLuckMsg(@Query("user_token") String userToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(StoreApi.class, true, 1).postLuckMsg(userToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<EmptyInfo>> receiveCoupon(@Query("user_token") String userToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(StoreApi.class, true, 1).receiveCoupon(userToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<EmptyInfo>> couponExchange(@Query("user_token") String userToken, @Query("service") String service, @Query("params") String jsonParams) {
        return RetrofitHelper.createApi(StoreApi.class, true, 1).couponExchange(userToken, service, jsonParams).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<DSKBean>> getDskInfo(@Query("user_token") String userToken, @Query("service") String service, @Query("params") String jsonParams) {
        return RetrofitHelper.createApi(StoreApi.class, true, 1).getDskInfo(userToken, service, jsonParams).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<DskStoreDetailBean>> getStoreDskInfo(@Query("user_token") String userToken, @Query("service") String service, @Query("page") String pageParams, @Query("params") String jsonParams) {
        return RetrofitHelper.createApi(StoreApi.class, true, 1).getStoreDskInfo(userToken, service, pageParams, jsonParams).compose(RxUtils.rxSchedulerHelper());
    }
}
